<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="https://muyao1987.gitee.io/cdn/marsgis.cn/favicon/favicon.ico" />
    <title>成像范围计算 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="/lib/include-lib.js"
      libpath="/lib/"
      include="jquery,layer,toastr,jquery.minicolors,layer,font-awesome,jedate,bootstrap,bootstrap-checkbox,bootstrap-slider,admui-frame,haoutil,mars3d,mars3d-space"
    ></script>

    <link href="/css/style.css" rel="stylesheet" />
    <style>
      .slider.slider-horizontal {
        width: 186px;
        height: 20px;
        margin-top: 5px;
      }
    </style>
  </head>

  <body class="dark">
    <div id="mars3dContainer" class="mars3d-container"></div>

    <!-- 面板 -->
    <div class="infoview">
      <table class="mars-table">
        <tr>
          <td class="nametd">卫星张角：</td>
          <td>
            <input id="txtAngle" />
          </td>
        </tr>
        <tr>
          <td class="nametd">开始时间：</td>
          <td>
            <input type="text" class="form-control" id="txtStartTime" placeholder="YYYY-MM-DD" />
          </td>
        </tr>

        <tr>
          <td class="nametd">结束时间：</td>
          <td>
            <input type="text" class="form-control" id="txtEndTime" placeholder="YYYY-MM-DD" />
          </td>
        </tr>

        <tr>
          <td class="nametd">区域颜色：</td>
          <td>
            <input type="text" id="txtColor" class="form-control" style="width: 100%" value="#ff0000" />
          </td>
        </tr>

        <tr>
          <td class="nametd">区域透明度:</td>
          <td>
            <input type="text" id="txtColor" class="form-control" style="width: 100%" value="#ff0000" />
          </td>
        </tr>
      </table>

      <form class="form-horizontal">
        <div class="form-group" style="text-align: center">
          <input id="btnAdd" type="button" class="btn btn-primary" value="计算成像区域" />
          <input id="btnRemoveAll" type="button" class="btn btn-danger" value="清除所有" />
        </div>

        <div class="form-group" style="text-align: center">
          <div class="col-xs-offset-3 col-sm-offset-3 col-xs-9 col-sm-9">
            <div class="checkbox checkbox-primary checkbox-inline">
              <input id="chkAngleS" class="styled" type="checkbox" checked />
              <label for="chkAngleS"> 升轨 </label>
            </div>
            <div class="checkbox checkbox-primary checkbox-inline">
              <input id="chkAngleJ" class="styled" type="checkbox" checked />
              <label for="chkAngleJ"> 降轨 </label>
            </div>
          </div>
        </div>
      </form>
    </div>

    <script src="/js/common.js"></script>
    <script src="./map.js"></script>
    <script type="text/javascript">
      "use script" //开发环境建议开启严格模式

      let formState = {
        slideAngle: 10,
        slideOpacity: 0.4,
        startTime: null,
        endTime: null,
        areaColor: "red",
        guidaoS: true,
        guidaoJ: true
      }

      function initUI(options) {
        //ui相关
        // eslint-disable-next-line no-undef
        jeDate("#txtStartTime", {
          theme: {
            bgcolor: "#135b91",
            pnColor: "#00CCFF"
          },
          format: "YYYY-MM-DD hh:mm:ss",
          zIndex: 20210825
        })
        // eslint-disable-next-line no-undef
        jeDate("#txtEndTime", {
          theme: {
            bgcolor: "#135b91",
            pnColor: "#00CCFF"
          },
          format: "YYYY-MM-DD hh:mm:ss",
          zIndex: 20210825
        })

        let now = Cesium.JulianDate.toDate(map.clock.currentTime)
        $("#txtStartTime").val(now.format("yyyy-MM-dd HH:mm:ss"))

        now.setMinutes(now.getMinutes() + 60)
        $("#txtEndTime").val(now.format("yyyy-MM-dd HH:mm:ss"))

        $("#txtColor").minicolors({
          position: "bottom left",
          control: "saturation",
          change: function (hex) {
            let opacity = Number($("#txtOpacity").val())
            formState.areaColor = hex
            changeColorOpacity(formState)
          }
        })

        map.on(mars3d.EventType.click, function (e) {
          $("#txtColor").minicolors("hide")
        })

        $("#txtOpacity")
          .slider({ min: 0.01, max: 1.0, step: 0.01, value: 0.4 })
          .on("change", (e) => {
            if (e && e.value) {
              formState.slideOpacity = e.value.newValue
              changeColorOpacity(formState)
            }
          })

        $("#txtAngle")
          .slider({ min: 1, max: 70, step: 1, value: 10 })
          .on("change", (e) => {
            if (e && e.value) {
              formState.slideAngle = e.value.newValue
              changeAngle(e.value.newValue)
            }
          })

        $("#chkAngleS").change(function () {
          let val = $(this).is(":checked")
          formState.guidaoS = val
          changeGuidaoS(val)
        })

        $("#chkAngleJ").change(function () {
          let val = $(this).is(":checked")
          formState.guidaoJ = val
          changeGuidaoJ(val)
        })

        $("#btnAdd").click(function () {
          btnAdd(formState)
          console.log(formState)
        })

        $("#btnRemoveAll").click(function () {
          btnRemoveAll()
        })
      }

      eventTarget.on("loadStatellite", (event) => {
        formState.startTime = event.startTime
        $("#txtStartTime").val(formState.startTime)
        formState.endTime = event.endTime
        $("#txtEndTime").val(formState.endTime)
      })
    </script>
  </body>
</html>
